﻿
using Dora.Orm.Core.Domain.Entities;
using Dora.Services.AdminUser.Dto.QueryDto;
using Dora.Services.AdminUser.Entities;
using Dora.Tools.Utility.Const;
using Surging.Core.Common;
using Surging.Core.CPlatform.Ioc;
using Surging.Core.CPlatform.Runtime.Server.Implementation.ServiceDiscovery.Attributes;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Dora.Services.AdminUser.Dto.SaveDto;
using Dora.Services.AdminUser.Dto.ViewDto;
using Dora.Tools.Enums.AdminUser;

namespace Dora.Services.AdminUser.IApplication
{
    /// <summary>
    /// 角色表服务接口
    /// </summary>
    [ServiceBundle("api/" + DoraModuleName.AdminUser + "/{Service}")]
    public interface IRoleService : IServiceKey
    {

        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "创建")]
        Task<ResultDto<RoleEntity>> Create(RoleEntity entity);

        /// <summary>
        /// 根据Id获取一个实体对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "根据Id获取一个实体对象")]
        Task<RoleEntity> GetById(Guid id);

        /// <summary>
        /// 分页获取数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "分页获取数据")]
        Task<PageDataList<RoleViewDto>> GetPageList(RoleQueryDto input);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "修改")]
        Task<ResultDto> Update(RoleEntity entity);

        /// <summary>
        /// 根据IdList获取列表
        /// </summary>
        /// <param name="idList"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "根据IdList获取列表")]
        Task<List<RoleEntity>> GetList(List<Guid> idList);

        /// <summary>
        /// 获取所有
        /// </summary>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "获取所有")]
        Task<List<RoleEntity>> GetAll();

        /// <summary>
        /// 保存角色权限
        /// </summary>
        /// <returns></returns>
        [Service(Date = "2019-04-29", Director = "TTTan", Name = "保存角色权限")]
        Task<int> SaveRolePermission(RolePermissionSaveDto input);
        
        [Service(Date = "2019-04-30", Director = "TTTan", Name = "删除角色")]
        Task<ResultDto<bool>> Delete(RoleEntity entity);

        [Service(Date = "2019-04-30", Director = "TTTan", Name = "通过编号获取员工角色")]
        Task<RoleEntity> GetByRoleNo(string roleNo);
        
        [Service(Date = "2019-04-30", Director = "TTTan", Name = "批量禁用角色")]
        Task<bool> BatchDisable(List<Guid> listIds, string updatedUserName, Guid updatedUserId);

        [Service(Date = "2019-04-30", Director = "TTTan", Name = "批量启用角色")]
        Task<bool> BatchEnable(List<Guid> listIds, string updatedUserName, Guid updatedUserId);
        
        /// <summary>
        /// 获取被授予的角色列表
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-30", Director = "TTTan", Name = "获取被授予的角色列表")]
        Task<List<RoleEntity>> GetDoraAuthedList(Guid userId);

        /// <summary>
        /// 获取自己创建的角色列表
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-30", Director = "TTTan", Name = "获取自己创建的角色列表")]
        Task<List<RoleEntity>> GetCreatedList(Guid userId);

        /// <summary>
        /// 获取自己创建的和被授予的角色列表
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-30", Director = "TTTan", Name = "获取自己创建的和被授予的角色列表")]
        Task<List<RoleEntity>> GetDoraAuthedAndCreatedList(Guid userId);

        /// <summary>
        /// 根据系统Key获取列表
        /// </summary>
        /// <param name="systemKey"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-30", Director = "TTTan", Name = "根据系统Key获取角色列表")]
        Task<List<RoleEntity>> GetListBySystemKey(string systemKey);
        /// <summary>
        /// 角色编号是否存在
        /// </summary>
        /// <param name="systemKey"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-08", Director = "TTTan", Name = "角色编号是否存在")]
        Task<bool> ExistRoleNO(Guid id, string roleNO);

        /// <summary>
        /// 获取某个系统的所有权限，如果RoleId不为empty,并且把这个角色在这个系统拥有的权限打上标记
        /// </summary>
        /// <param name="systemKey"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-08", Director = "TTTan", Name = "获取某个系统的所有权限，如果RoleId不为empty,并且把这个角色在这个系统拥有的权限打上标记")]
        Task<PermissionsWithTreeDto> GetPermissionsWithTreeByRoleId(Guid roleId);

        /// <summary>
        /// 获取某个系统某个权限组织机构类型与通用的所有权限，如果RoleId不为empty,并且把这个角色在这个系统拥有的权限打上标记
        /// </summary>
        /// <param name="systemKey"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-30", Director = "TTTan", Name = "获取某个系统某个权限组织机构类型与通用的所有权限，如果RoleId不为empty,并且把这个角色在这个系统拥有的权限打上标记")]
        Task<PermissionsWithTreeDto> GetPermissionsWithTreeByRoleIdAndOrgType(Guid roleId, PermissionOrgType orgType);

        /// <summary>
        /// 获取用户在某个机构下所拥有或创建的角色
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-17", Director = "TTTan", Name = "获取用户在某个机构下所拥有或创建的角色")]
        Task<List<RoleEntity>> GetTasAuthedAndCreatedList(Guid userId, int orgId);

        /// <summary>
        /// 获取用户在某个机构下所拥有的角色
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-17", Director = "TTTan", Name = "获取用户在某个机构下所拥有的角色")]
        Task<List<RoleEntity>> GetTasAuthedList(Guid userId, int orgId);

        /// <summary>
        /// 根据系统Key和组织机构Id获取列表
        /// </summary>
        /// <param name="systemKey"></param>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-17", Director = "TTTan", Name = "根据系统Key和组织机构Id获取列表")]
        Task<List<RoleEntity>> GetListBySystemKeyAndOrgId(string systemKey, int orgId);

        /// <summary>
        /// 根据系统Key,组织机构Id和权限组织机构类型获取列表
        /// </summary>
        /// <param name="systemKey"></param>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-30", Director = "TTTan", Name = "根据系统Key和组织机构Id获取列表")]
        Task<List<RoleEntity>> GetListBySystemKeyOrgIdAndOrgType(string systemKey, int orgId, PermissionOrgType orgType);
    }
}
